home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-08-02 | 22.5 KB | 737 lines | [TEXT/PJMM] |
- unit ListUtilities;
- interface
- uses
- KeyBoard, Memory, Sane, StringUtilities;
- type
- ListGlobalType = record
- window: WindowPtr;{the window which owns the list}
- nListItem: integer;{item number in the dialog}
- Box: rect;{box of the entire list including the scroll bars}
- List: ListHandle;
-
- selCell: cell;{cell corresponding to the TE record}
- multiple: boolean;{is more than one cell selected?}
- TEexists: boolean;
- hTE: TEHandle;
- TErect: rect;
- largeTERect: boolean;
-
- doubleClick: boolean;
-
- Editable: packed array[0..30] of boolean;{is that column editable?}
- Number: packed array[0..30] of boolean; {these specify which columns are numbers and which contain general text}
- Integer: packed array[0..30] of boolean; {furthermore, should the column be restricted to integer quantities}
- end;
- ListGlobalPtr = ^ListGlobalType;
- ListGlobalHandle = ^ListGlobalPtr;
- function ListFilterProc (Dlg: WindowPtr;
- var theEvent: EventRecord;
- var ItemHit: integer): boolean;
- procedure SetUpListItem (Dlg: DialogPtr;
- nListItem: integer;
- var ListGlobal: ListGlobalHandle;
- cols, rows: integer);
- procedure SetUpList (w: WindowPtr;
- var ListGlobal: ListGlobalHandle;
- box: rect;{including the scroll bars}
- cols, rows: integer);
- procedure DisposeListGlobal (ListGlobal: ListGlobalHandle);
- procedure HandleListKey (ListGlobal: ListGlobalHandle;
- theKeyCode: integer;
- theChar: char;
- Modifiers: integer);
- procedure DragGrayRect (startPoint: point;
- var dragRect: rect);
-
- procedure UpdateLargeTERect (ListGlobal: ListGlobalHandle);
-
- function LGetCellString (theCell: Cell;
- List: ListHandle): str255;
- function LGetCellNumber (theCell: Cell;
- List: ListHandle): extended;
- procedure LSetCellString (theStr: str255;
- theCell: Cell;
- List: ListHandle);
- procedure LSetCellNumber (theNum: extended;
- decimals, SigFigures: integer;
- theCell: Cell;
- List: ListHandle);
-
- procedure SetUpCell (where: point;
- ListGlobal: ListGlobalHandle);
- procedure SetUpCell2 (theCell: cell;
- ListGlobal: ListGlobalHandle);
- procedure DisposeCell (ListGlobal: ListGlobalHandle);
- procedure ClearListSelection (ListGlobal: ListGlobalHandle);
-
- procedure InsertRow (ListGlobal: ListGlobalHandle);
- procedure AppendRow (ListGlobal: ListGlobalHandle);
- procedure DeleteRow (ListGlobal: ListGlobalHandle);
-
- implementation
- {*********************************************}
- procedure MoveTERect (ListGlobal: ListGlobalHandle;
- where: point);
- var
- newTERect: rect;
- theText: handle;
- error: boolean;
- begin
- newTERect := ListGlobal^^.TERect;
- DragGrayRect(where, newTERect);
- {now, move the TERect}
- theText := handle(TEGetText(ListGlobal^^.hTE));
- myHandToHand(theText, error);
- TEDispose(ListGlobal^^.hTE);
- ListGlobal^^.hTE := TENew(newTERect, newTERect);
- TESetText(theText^, gethandlesize(theText), ListGlobal^^.hTE);
- DisposHandle(theText);
- {update the list hidden by the old rect}
- UpdateLargeTERect(ListGlobal);
- {redraw any obscured controls}
- DrawControls(ListGlobal^^.window);
- {draw the box and the text}
- ListGlobal^^.TERect := newTERect;
- EraseRect(ListGlobal^^.TERect);
- InsetRect(ListGlobal^^.TERect, -1, -1);
- FrameRect(ListGlobal^^.TERect);
- InsetRect(ListGlobal^^.TERect, 1, 1);
- TEAutoView(true, ListGlobal^^.hTE);
- TEActivate(ListGlobal^^.hTE);
- TEUpdate(ListGlobal^^.TERect, ListGlobal^^.hTE);
- end;
- {*********************************************}
- procedure CutCopyClearList (ListGlobal: ListGlobalHandle;
- whichKey: integer);
- var
- error: boolean;
- theText: handle;
- theCell: Cell;
- ClipOffset, ClipResult: longint;
- lastRow: integer;
- done: boolean;
- err: OSErr;
- begin
- error := false;
- DisposeCell(ListGlobal);
- LSetSelect(true, ListGlobal^^.selCell, ListGlobal^^.List);
- theText := mynewhandle(0, error);
- SetPt(theCell, 0, 0);
- lastRow := 10000;
- done := true;
- while done and LGetSelect(true, theCell, ListGlobal^^.List) do
- begin
- if theCell.v > lastRow then
- AppendString(theText, CR, error);
- if theCell.v = lastRow then
- AppendString(theText, tab, error);
- AppendString(theText, LGetCellString(theCell, ListGlobal^^.List), error);
- case whichKey of
- xKey, dummyClearKey:
- LClrCell(theCell, ListGlobal^^.List);
- end;{case}
- lastRow := theCell.v;
- done := LNextCell(true, true, theCell, ListGlobal^^.List);
- end;
- if not (whichKey = dummyClearKey) then
- begin
- err := ZeroScrap;
- err := PutScrap(gethandlesize(theText), 'TEXT', theText^);
- end;
- DisposHandle(theText);
- SetUpCell2(ListGlobal^^.selCell, ListGlobal);
- TESetSelect(0, 0, ListGlobal^^.hTE);
- end;
- {*********************************************}
- procedure PasteList (ListGlobal: ListGlobalHandle;
- OptionPressed: boolean);
- var
- error: boolean;
- theText: CharsHandle;
- ClipOffset, ClipResult, len, i: longint;
- firstCell, theCell: Cell;
- begin{paste}
- error := false;
- DisposeCell(ListGlobal);
- theText := CharsHandle(mynewhandle(0, error));
- ClipOffset := 0;
- ClipResult := GetScrap(handle(theText), 'TEXT', ClipOffset);
- firstCell := ListGlobal^^.selCell;
- theCell := firstCell;
- len := gethandlesize(handle(theText));
- if len > 0 then
- LClrCell(theCell, ListGlobal^^.List);
- for i := 0 to len - 1 do
- begin
- if theText^^[i] = CR then
- begin
- theCell.h := firstCell.h;
- if OptionPressed then
- begin
- theCell.v := theCell.v + 1;
- if not PtInRect(theCell, ListGlobal^^.List^^.dataBounds) then
- theCell.v := LAddRow(1, theCell.v + 1, ListGlobal^^.List);
- end
- else
- theCell.v := LAddRow(1, theCell.v + 1, ListGlobal^^.List);
- if ListGlobal^^.editable[theCell.h] then
- LClrCell(theCell, ListGlobal^^.List);
- end
- else if (theText^^[i] = tab) or (theText^^[i] = comma) then
- begin
- theCell.h := theCell.h + 1;
- if ListGlobal^^.editable[theCell.h] then
- LClrCell(theCell, ListGlobal^^.List);
- end
- else if PtInRect(theCell, ListGlobal^^.List^^.dataBounds) then
- if ListGlobal^^.editable[theCell.h] then
- LAddToCell(@theText^^[i], 1, theCell, ListGlobal^^.List);
- end;
- DisposHandle(handle(theText));
- ClearListSelection(ListGlobal);
- end;
- {*********************************************}
- procedure HandleListKey (ListGlobal: ListGlobalHandle;
- theKeyCode: integer;
- theChar: char;
- Modifiers: integer);
- var
- theCell: Cell;
- error: boolean;
- theText: handle;
- LastString, theString: Str255;
- begin
- error := false;
- if BitAnd(modifiers, CmdKey) = CmdKey then
- case theKeyCode of
- xKey:
- CutCopyClearList(ListGlobal, xKey);
- cKey:
- CutCopyClearList(ListGlobal, cKey);
- vKey, dummyOptionPasteKey:
- PasteList(ListGlobal, OptionKeyDown or (theKeyCode = dummyOptionPasteKey));
- dummyClearKey:
- CutCopyClearList(ListGlobal, dummyClearKey);
- end
- else
- begin
- case WhichCursor(theKeyCode) of
- RightCurs, TabCurs:
- begin
- theCell := ListGlobal^^.selCell;
- theCell.h := theCell.h + 1;
- DisposeCell(ListGlobal);
- SetUpCell2(theCell, ListGlobal);
- end; {tab}
- DownCurs, Carriage:
- begin{carriage return}
- theCell := ListGlobal^^.selCell;
- theCell.v := theCell.v + 1;
- DisposeCell(ListGlobal);
- SetupCell2(theCell, ListGlobal);
- end; {carriage return}
- LeftCurs:
- begin{left}
- theCell := ListGlobal^^.selCell;
- theCell.h := theCell.h - 1;
- DisposeCell(ListGlobal);
- SetupCell2(theCell, ListGlobal);
- end;{left}
- UpCurs:
- begin{up}
- theCell := ListGlobal^^.selCell;
- theCell.v := theCell.v - 1;
- DisposeCell(ListGlobal);
- SetupCell2(theCell, ListGlobal);
- end;{up}
- otherwise
- begin
- if ListGlobal^^.number[ListGlobal^^.selCell.h] then
- begin
- error := false;
- theText := handle(TEGetText(ListGlobal^^.hTE));
- handletoStr255(theText, LastString, error);
- end;
- TEKey(theChar, ListGlobal^^.hTE);
- if ListGlobal^^.number[ListGlobal^^.selCell.h] then{check that it is a number}
- begin
- theText := handle(TEGetText(ListGlobal^^.hTE));
- handletoStr255(ListGlobal^^.hTE^^.hText, theString, error);
- if not IsNumber(theString, ListGlobal^^.integer[ListGlobal^^.selCell.h]) then
- begin
- sysbeep(60);
- TESetSelect(0, 32000, ListGlobal^^.hTE);
- TEDelete(ListGlobal^^.hTE);
- TESetText(ptrtoString(LastString), length(LastString), ListGlobal^^.hTE);
- TEUpdate(ListGlobal^^.TErect, ListGlobal^^.hTE);
- end;
- end;
- end;
- end;
- end;
- end;
- {*********************************************}
- function ListFilterProc (Dlg: DialogPtr;
- var theEvent: EventRecord;
- var ItemHit: integer): boolean;
- type
- FourChars = packed record
- case integer of
- 0: (
- one, two, three, four: char
- );
- 1: (
- b1, b2, b3, b4: byte
- );
- end;
- var
- where: point;
- ListGlobal: ListGlobalHandle;
- theCell: cell;
- error, doubleClick: boolean;
- theChar: char;
- theKeyCode: byte;
- ignore: boolean;
-
- theItem, itemType: integer;
- item: handle;
- box: rect;
- begin
- ListFilterProc := false;
- where := theEvent.where;
- GlobalToLocal(where);
- ListGlobal := ListGlobalHandle(WindowPeek(Dlg)^.refCon);
-
- {check if the user is terminating the dialog with the Enter key}
- if theEvent.what = KeyDown then
- begin{enter key}
- theChar := FourChars(theEvent.message).four;
- theKeyCode := FourChars(theEvent.message).b3;
- if theKeyCode = EnterKey then
- begin
- ListFilterProc := true;
- itemHit := 1;
- end;
- end;
-
- if ListGlobal^^.TEExists then
- begin{TEExists}
- TEIdle(ListGlobal^^.hTE);
- ListFilterProc := true;
- itemHit := ListGlobal^^.nListItem;
- case theEvent.what of
- mouseDown:
- if PtInRect(where, ListGlobal^^.TErect) then
- begin{it is a TE event}
- if (theEvent.modifiers = OptionKey) and ListGlobal^^.largeTErect then
- MoveTERect(ListGlobal, where)
- else{just click in the TE rect}
- TEClick(where, (theEvent.modifiers = ShiftKey), ListGlobal^^.hTE);
- end{it is a TE event}
- else if PtInRect(where, ListGlobal^^.box) then
- begin{check other cells}
- DisposeCell(ListGlobal);
- {check if another cell was clicked in}
- ignore := ListFilterProc(Dlg, theEvent, itemHit);
- end
- else
- begin{not a list event}
- {check if the user clicked in a EditText item, if so, we must eliminate our insertion point}
- theItem := FindDItem(Dlg, where) + 1;{FindDItem is zero based}
- if theItem > 0 then
- begin
- GetDItem(Dlg, theItem, itemType, item, box);
- if itemType = editText then
- DisposeCell(ListGlobal);
- end;
- ListFilterProc := false;
- end;{not a list event}
-
- KeyDown:
- HandleListKey(ListGlobal, theKeyCode, theChar, theEvent.modifiers);
-
- end;{case}
- end{TEExists}
- {now process events when no TE record exists}
- else if (theEvent.what = mouseDown) and PtInRect(where, ListGlobal^^.box) then
- begin
- ListFilterProc := true;
- itemHit := ListGlobal^^.nListItem;
- if theEvent.modifiers <> ShiftKey then
- ClearListSelection(ListGlobal);{reselect the original cell}
- ListGlobal^^.doubleClick := LClick(where, theEvent.modifiers, ListGlobal^^.List);
- GetMouse(where);
- theCell.h := 0;
- theCell.v := 0;
- {The following is a fancy way of determining whether a single cell or a group of cells were selected}
- if LGetSelect(true, theCell, ListGlobal^^.List) then
- begin
- if (not LNextCell(true, true, theCell, ListGlobal^^.List)) or (not LGetSelect(true, theCell, ListGlobal^^.List)) then
- begin{only a single cell was selected}
- doubleClick := LClick(where, theEvent.modifiers, ListGlobal^^.List);
- GetMouse(where);
- SetupCell(where, ListGlobal);
- ListGlobal^^.multiple := false;
- end
- else
- begin{multiple selection}
- theCell.h := 0;
- theCell.v := 0;
- if LGetSelect(true, theCell, ListGlobal^^.List) then
- begin
- SetUpCell2(theCell, ListGlobal);
- TESetSelect(0, 0, ListGlobal^^.hTE);
- ListGlobal^^.multiple := true;
- end;
- end;{multiple selection}
- end;
- end
- end;
- {*************************************************}
- procedure ListActionProc (Dlg: DialogPtr;
- itemNo: integer);
- var
- itemType: integer;
- item: handle;
- box: rect;
- boxRgn: RgnHandle;
- ListGlobal: ListGlobalHandle;
- begin
- GetDItem(Dlg, itemNo, itemType, item, box);
- boxRgn := NewRgn;
- RectRgn(boxRgn, Dlg^.portRect);
- longint(ListGlobal) := WindowPeek(Dlg)^.RefCon;
- LUpdate(boxRgn, ListGlobal^^.List);
- DisposeRgn(boxRgn);
-
- box := ListGlobal^^.List^^.rView;
- InsetRect(box, -1, -1);
- FrameRect(box);
- end;
- {*************************************************}
- procedure SetUpListItem (Dlg: DialogPtr;
- nListItem: integer;
- var ListGlobal: ListGlobalHandle;
- cols, rows: integer);
- var
- error: boolean;
- itemType: integer;
- item: handle;
- box: rect;
- begin
- error := false;
- GetDItem(Dlg, nListItem, itemType, item, box);
- SetDItem(Dlg, nListItem, itemType, handle(@ListActionProc), box);
- ShowWindow(Dlg);
-
- SetUpList(Dlg, ListGlobal, box, cols, rows);
- ListGlobal^^.nListItem := nListItem;
- end;
- {*************************************}
- procedure SetUpList;
- var
- error: boolean;
- rView, dataBounds: rect;
- cSize: point;
- i: integer;
- theFont: fontInfo;
- nRows: integer;
- begin
- error := false;
- ListGlobal := ListGlobalHandle(myNewHandle(sizeof(ListGlobalType), error));
- WindowPeek(w)^.RefCon := longint(ListGlobal);
- ListGlobal^^.window := w;
- ListGlobal^^.box := box;
- ListGlobal^^.TEExists := false;
- ListGlobal^^.doubleClick := false;
- GetFontInfo(theFont);
- rView := box;
- rView.right := rView.right - 15;
- SetRect(dataBounds, 0, 0, cols, rows);
- cSize.h := (rView.right - rView.left) div dataBounds.right;
- nRows := ((rView.bottom - rView.top) div (theFont.ascent + theFont.descent));
- cSize.v := (rView.bottom - rView.top) div nRows;
- rView.bottom := rView.top + cSize.v * nRows;
- ListGlobal^^.List := LNew(rView, dataBounds, cSize, 0, w, true, false, false, true);
- InsetRect(rView, -1, -1);
- FrameRect(rView);
- for i := 0 to cols - 1 do
- begin
- ListGlobal^^.editable[i] := true;
- ListGlobal^^.number[i] := true;
- ListGlobal^^.integer[i] := false;
- end;
- end;
- {*************************************************}
- procedure DisposeListGlobal (ListGlobal: ListGlobalHandle);
- begin
- DisposeCell(ListGlobal);
- LDispose(ListGlobal^^.List);
- DisposHandle(handle(ListGlobal));
- end;
- {*************************************************}
- procedure UpdateLargeTERect;
- var
- UpdateRgn: RgnHandle;
- rView: rect;
- begin
- UpdateRgn := NewRgn;
- InsetRect(ListGlobal^^.TERect, -1, -1);
- EraseRect(ListGlobal^^.TERect);
- RectRgn(UpdateRgn, ListGlobal^^.TERect);
- LUpdate(UpdateRgn, ListGlobal^^.List);
- DisposeRgn(UpdateRgn);
- rView := ListGlobal^^.List^^.rView;
- InsetRect(rView, -1, -1);
- FrameRect(rView);
- end;
- {*************************************************}
- procedure DragGrayRect;
- var
- SavePen: PenState;
- newMouse, oldMouse: point;
- begin
- GetPenState(SavePen);
- PenMode(PatXor);{redrawing the same rect causes it to be erased}
- PenPat(gray);
-
- oldMouse := startPoint;
- FrameRect(dragRect);
- repeat{check to see if it is torn off}
- GetMouse(newMouse);
- if not EqualPt(newMouse, oldMouse) then
- begin
- FrameRect(dragRect);{erase}
- OffsetRect(dragRect, newMouse.h - oldMouse.h, newMouse.v - oldMouse.v);
- oldMouse := newMouse;
- FrameRect(dragRect);{redraw}
- end;
- until not Button;{check to see if it is torn off}
- FrameRect(dragRect);
-
- SetPenState(SavePen);
- end;
- {*************************************************}
- procedure VerifyCell (var theCell: Cell;
- theList: ListHandle);
- begin
- if theCell.h < 0 then
- begin
- theCell.h := theList^^.dataBounds.right - 1;
- theCell.v := theCell.v - 1;
- if theCell.v < 0 then
- theCell.v := theList^^.dataBounds.bottom - 1;
- end;
- if theCell.v < 0 then
- begin
- theCell.v := theList^^.dataBounds.bottom - 1;
- theCell.h := theCell.h - 1;
- if theCell.h < 0 then
- theCell.h := theList^^.dataBounds.right - 1;
- end;
- if theCell.h >= theList^^.dataBounds.right then
- begin
- theCell.h := 0;
- theCell.v := theCell.v + 1;
- if theCell.v >= theList^^.dataBounds.bottom then
- theCell.v := 0;
- end;
- if theCell.v >= theList^^.dataBounds.bottom then
- begin
- theCell.v := 0;
- theCell.h := theCell.h + 1;
- if theCell.h >= theList^^.dataBounds.right then
- theCell.h := 0;
- end;
- end;
- {***********************************************}
- procedure LInitRow (ListGlobal: ListGlobalHandle;
- row: integer);
- var
- i: integer;
- theCell: Cell;
- begin
- theCell.v := row;
- theCell.h := 0;
-
- if not ListGlobal^^.number[0] then
- LSetCellString('blank', theCell, ListGlobal^^.List);
-
- for i := 1 to ListGlobal^^.List^^.dataBounds.right do
- if ListGlobal^^.number[i - 1] then
- begin
- theCell.h := i - 1;
- LSetCellNumber(0, 0, 0, theCell, ListGlobal^^.List);
- end;
- theCell.h := 0;
- SetupCell2(theCell, ListGlobal);
- end;
- {***********************************************}
- procedure InsertRow;
- var
- row: integer;
- begin
- if PtInRect(ListGlobal^^.selCell, ListGlobal^^.List^^.dataBounds) then
- begin
- DisposeCell(ListGlobal);
- row := ListGlobal^^.selCell.v;
- row := LAddRow(1, row, ListGlobal^^.List);
- LInitRow(ListGlobal, row);
- end;
- end;
- {*************************************************}
- procedure AppendRow;
- var
- row: integer;
- begin
- DisposeCell(ListGlobal);
- row := LAddRow(1, 10000, ListGlobal^^.List);
- LInitRow(ListGlobal, row);
- end;
- {*************************************************}
- procedure DeleteRow;
- var
- theCell: cell;
- begin
- if PtInRect(ListGlobal^^.selCell, ListGlobal^^.List^^.dataBounds) then
- begin
- theCell := ListGlobal^^.selCell;
- DisposeCell(ListGlobal);
- LDelRow(1, theCell.v, ListGlobal^^.List);
- if theCell.v > 0 then
- theCell.v := theCell.v - 1;
- if ListGlobal^^.List^^.databounds.bottom > 0 then
- SetupCell2(theCell, ListGlobal);
- end;
- end;
- {*************************************************}
- procedure SetUpCell2;
- var
- cellRect: rect;
- begin
- VerifyCell(theCell, ListGlobal^^.List);
- LSetSelect(true, theCell, ListGlobal^^.List);
- LAutoScroll(ListGlobal^^.List);
-
- LRect(cellRect, theCell, ListGlobal^^.List);
- SetUpCell(cellRect.topLeft, ListGlobal);
- if ListGlobal^^.TEExists then
- TESetSelect(0, 32000, ListGlobal^^.hTE);
- end;
- {*************************************************}
- procedure SetUpCell;
- var
- theData: ptr;
- dataLen: integer;
- ignore: boolean;
- width: integer;
- begin
- ignore := LClick(where, 0, ListGlobal^^.List);
- ListGlobal^^.selCell := LLastClick(ListGlobal^^.List);
- if PtInRect(ListGlobal^^.selCell, ListGlobal^^.List^^.dataBounds) and ListGlobal^^.editable[ListGlobal^^.selCell.h] then
- begin
- ListGlobal^^.TEExists := true;
- LSetSelect(true, ListGlobal^^.selCell, ListGlobal^^.List);
- LRect(ListGlobal^^.TERect, ListGlobal^^.selCell, ListGlobal^^.List);
- ignore := LClick(ListGlobal^^.TERect.topLeft, 0, ListGlobal^^.List);{clear the old cell}
- theData := NewPtr(255);
- dataLen := 255;
- LGetCell(theData, dataLen, ListGlobal^^.selCell, ListGlobal^^.List);
- width := TextWidth(theData, 0, dataLen);
- {check if the text is too wide for the cell}
- if width > (ListGlobal^^.TERect.right - ListGlobal^^.TERect.left) then
- begin
- ListGlobal^^.TERect.right := ListGlobal^^.TERect.left + 3 * (ListGlobal^^.TERect.right - ListGlobal^^.TERect.left);
- ListGlobal^^.TERect.bottom := ListGlobal^^.TERect.top + 2 * (ListGlobal^^.TERect.bottom - ListGlobal^^.TERect.top);
- {CheckOnScreen(ListGlobal^^.TERect);}
- InsetRect(ListGlobal^^.TERect, -1, -1);
- FrameRect(ListGlobal^^.TERect);
- InsetRect(ListGlobal^^.TERect, 1, 1);
- ListGlobal^^.largeTERect := true;
- end
- else
- ListGlobal^^.largeTERect := false;
-
- ListGlobal^^.hTE := TENew(ListGlobal^^.TERect, ListGlobal^^.TERect);
- TEAutoView(true, ListGlobal^^.hTE);
- TESetText(theData, dataLen, ListGlobal^^.hTE);
- DisposPtr(theData);
- TEActivate(ListGlobal^^.hTE);
- EraseRect(ListGlobal^^.TERect);
- TEUpdate(ListGlobal^^.TERect, ListGlobal^^.hTE);
-
- TEClick(where, false, ListGlobal^^.hTE)
- end;
- end;
- {*************************************************}
- procedure DisposeCell;
- var
- error: boolean;
- theString: str255;
- theText: handle;
- begin
- if ListGlobal^^.TEExists then
- begin
- ListGlobal^^.TEExists := false;
- error := false;
- theText := handle(TEGetText(ListGlobal^^.hTE));{does this handle need to be disposed??}
- HandleToStr255(theText, theString, error);
- TEDispose(ListGlobal^^.hTE);
- LSetCellString(theString, ListGlobal^^.selCell, ListGlobal^^.List);
- LSetSelect(false, ListGlobal^^.selCell, ListGlobal^^.List);
- if ListGlobal^^.largeTERect then
- UpdateLargeTERect(ListGlobal);
- end;
- end;
- {***********************************}
- procedure ClearListSelection (ListGlobal: ListGlobalHandle);
- var
- theCell: Cell;
- begin
- if ListGlobal^^.multiple then
- begin
- SetPt(theCell, 0, 0);
- while LGetSelect(true, theCell, ListGlobal^^.List) do
- LSetSelect(false, theCell, ListGlobal^^.List);
- end;
- end;
- {***********************************}
- function LGetCellNumber;
- begin
- LGetCellNumber := stringToReal(LGetCellString(theCell, List));
- end;
- {*************************************************}
- function LGetCellString;
- var
- theLen: integer;
- thePtr: ptr;
- theStr: str255;
- begin
- theLen := 255;
- thePtr := NewPtr(theLen);
- LGetCell(thePtr, theLen, theCell, List);
- theStr[0] := char(theLen);
- blockMove(thePtr, ptr(longint(@theStr) + 1), theLen);
- LGetCellString := theStr;
- DisposPtr(thePtr);
- end;
- {*************************************************}
- procedure LSetCellString (theStr: str255;
- theCell: Cell;
- List: ListHandle);
- begin
- LSetCell(ptr(longint(@theStr) + 1), length(theStr), theCell, List);
- end;
- {*************************************************}
- procedure LSetCellNumber (theNum: extended;
- decimals, SigFigures: integer;
- theCell: Cell;
- List: ListHandle);
- begin
- if SigFigures > 0 then
- LSetCellString(RealToString(theNum, SigFigures), theCell, List)
- else
- LSetCellString(RealToFixed(theNum, decimals), theCell, List);
- end;
- {***********************************************}
- end.